<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:template match="/">

<fo:root>
	<fo:layout-master-set>
		<fo:simple-page-master master-name="scheda" margin-bottom="1cm" margin-left="10mm" margin-top="10mm" margin-right="1cm" page-height="297mm" page-width="210mm">
			<fo:region-body margin-top="100mm" margin-bottom="10mm"></fo:region-body>
			<fo:region-before margin-top="5mm"></fo:region-before>
			<fo:region-after extent="5mm" margin-bottom="5mm" margin-right="5mm"></fo:region-after>
			
		</fo:simple-page-master>
	</fo:layout-master-set>
	<fo:page-sequence master-reference="scheda">

		<fo:static-content flow-name="xsl-region-before">
			<fo:block-container xsl:use-attribute-sets="border-style" border-width="2mm" height="60mm" width="190mm" top="2mm" padding=".6mm" position="absolute">
				<fo:block text-align="center"><fo:external-graphic src="url(http://ltw0807.web.cs.unibo.it/df/pdf/img/slide-tigelle.jpg)"></fo:external-graphic>
				</fo:block>
				<fo:block text-align="end" font-style="oblique">by Power Chiosco</fo:block>
			</fo:block-container>
			<fo:block-container border-color="black" border-style="hidden" border-width=".5mm" height="15mm" width="190mm" top="68mm" padding=".6mm" position="absolute">	
			<fo:table table-layout="fixed" width="190mm">
				<fo:table-column column-width="100mm"></fo:table-column>
				<fo:table-column column-width="90mm"></fo:table-column>
				<fo:table-body>
					<fo:table-row>
						<fo:table-cell>
							<fo:block xsl:use-attribute-sets="e-title"><xsl:value-of select="/dati/scheda/metadati/expression/etitle"></xsl:value-of></fo:block>
						</fo:table-cell>
						<fo:table-cell>
							<fo:block xsl:use-attribute-sets="e-creator">by <xsl:value-of select="/dati/scheda/metadati/expression/ecreator"></xsl:value-of></fo:block>
						</fo:table-cell>
					</fo:table-row>
					<fo:table-row>
						<fo:table-cell>
							<fo:block xsl:use-attribute-sets="w-att"> appartiene a "<xsl:value-of select="/dati/scheda/metadati/work/wtitle"></xsl:value-of>" by <xsl:value-of select="/dati/scheda/metadati/work/wcreator"></xsl:value-of></fo:block>
						</fo:table-cell>
							<fo:table-cell>
								<fo:block xsl:use-attribute-sets="page">Page <fo:page-number></fo:page-number></fo:block>
							</fo:table-cell>
					</fo:table-row>
				</fo:table-body>
			</fo:table>
			</fo:block-container>

		</fo:static-content>
		<fo:static-content flow-name="xsl-region-after">
			<fo:block xsl:use-attribute-sets="page">Page<fo:page-number></fo:page-number></fo:block>
		</fo:static-content>
		

		<fo:flow flow-name="xsl-region-body">
			
			<fo:block-container width="190mm" xsl:use-attribute-sets="layout-style">
				<fo:block xsl:use-attribute-sets="normal-text">
					<xsl:apply-templates select="/dati/scheda/body" />
				</fo:block>
			</fo:block-container>	
			
		</fo:flow>

	</fo:page-sequence>

</fo:root>
	</xsl:template>	
	
		<xsl:template match="/dati/scheda/body//h1"> 
			<fo:inline font-size="28pt" line-height="32pt" space-after="22pt"> <xsl:apply-templates select="*|text()"/></fo:inline>
		</xsl:template>	
		<xsl:template match="/dati/scheda/body//h2"> 
			<fo:inline font-size="24pt" line-height="28pt" space-after="18pt"><xsl:apply-templates select="*|text()"/></fo:inline>
		</xsl:template>	
		<xsl:template match="/dati/scheda/body//h3"> 
			<fo:inline font-size="21pt" line-height="24pt" space-after="14pt"><xsl:apply-templates select="*|text()"/></fo:inline>
		</xsl:template>	
		<xsl:template match="/dati/scheda/body//h4"> 
			<fo:inline font-size="18pt" line-height="21pt" space-after="12pt"><xsl:apply-templates select="*|text()"/></fo:inline>
		</xsl:template>	
		<xsl:template match="/dati/scheda/body//h5"> 
			<fo:inline font-size="16pt" line-height="19pt" space-after="12pt"><xsl:apply-templates select="*|text()"/></fo:inline>
		</xsl:template>	
		<xsl:template match="/dati/scheda/body//h6"> 
			<fo:inline font-size="14pt" line-height="17pt" space-after="12pt"><xsl:apply-templates select="*|text()"/></fo:inline>
		</xsl:template>	
		<xsl:template match="/dati/scheda/body//p">
			<fo:block font-size="12pt" line-height="15pt"
    space-after="12pt"><xsl:apply-templates select="*|text()"/></fo:block>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//a">
				<fo:basic-link xsl:use-attribute-sets="link-text" external-destination="{@href}">
				<fo:inline><xsl:value-of select="."></xsl:value-of>
				</fo:inline></fo:basic-link>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//div">
		<xsl:apply-templates select="*|text()"/>
		</xsl:template>
		
		<xsl:template match="/dati/scheda/body//img">
			<fo:block>
				<fo:external-graphic src="url({@src})"></fo:external-graphic>
			</fo:block>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//image">
			<fo:block>
				<fo:external-graphic src="{@src}" content-height="{@height}" content-width="{@width}"></fo:external-graphic>
			</fo:block>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//b">
			<fo:inline font-weight="bold"><xsl:apply-templates select="*|text()"/></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//i">
		<fo:inline font-style="italic"><xsl:apply-templates select="*|text()"/></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//strong">
		<fo:inline font-weight="bold"><xsl:apply-templates select="*|text()"/></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//big">
		<fo:inline font-size="16pt"><xsl:apply-templates select="*|text()"/></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//hr">
			<fo:block font-size="26pt" text-align="center">
			<fo:external-graphic src="url(http://ltw0807.web.cs.unibo.it/df/pdf/img/bahr.gif)"></fo:external-graphic>
			</fo:block>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//small">
		<fo:inline font-size="12pt"><xsl:apply-templates></xsl:apply-templates></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//sub">
		  <fo:inline vertical-align="sub" font-size="10pt">
			<xsl:apply-templates select="*|text()"/>
		  </fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//sup">
			  <fo:inline vertical-align="super" font-size="10pt">
			  <xsl:apply-templates select="*|text()"/></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//tt">
			<fo:inline font-family="monospace"><xsl:apply-templates></xsl:apply-templates></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//address">
			<fo:block font-style="italic"><xsl:apply-templates></xsl:apply-templates></fo:block>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//br">
			<fo:block> </fo:block>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//blockquote">
		  <fo:block start-indent="1.5cm" end-indent="1.5cm">
			<xsl:apply-templates select="*|text()"/></fo:block>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//pre">
			<fo:block font-family="monospace" white-space-collapse="false"><xsl:apply-templates select="*|text()" /></fo:block>
		</xsl:template>
		
		<!--List element-->
		<xsl:template match="/dati/scheda/body//dl">
			<fo:block> <xsl:apply-templates select="*|text()" /></fo:block>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//dt">
			<fo:block font-weight="bold"><xsl:apply-templates select="*|text()" /></fo:block>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//dd">
			<fo:block text-indent="10mm"><xsl:apply-templates select="*|text()" /></fo:block>
		</xsl:template>
		
		<xsl:template match="/dati/scheda/body//ol">
			<fo:block> <xsl:apply-templates select="*|text()" /></fo:block>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//ul">
			<fo:block><xsl:apply-templates select="*|text()" /></fo:block>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//li">
			<fo:block text-indent="10mm"> * <xsl:apply-templates select="*|text()" /></fo:block>
		</xsl:template>
		
		<!-- Element Inline -->
		<xsl:template match="/dati/scheda/body//abbr">
			<fo:inline><xsl:apply-templates select="*|text()" /></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//acronym">
			<fo:inline><xsl:apply-templates select="*|text()" /></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//cite">
			<fo:inline font-style="italic"><xsl:apply-templates select="*|text()" /></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//dfn">
			<fo:inline font-style="italic"><xsl:apply-templates select="*|text()" /></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//code">
			<fo:inline font-family="monospace" font-size="9pt"><xsl:apply-templates select="*|text()" /></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//em">
			<fo:inline font-style="italic"><xsl:apply-templates select="*|text()" /></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//kdb">
			<fo:inline font-family="monospace" font-size="9pt"><xsl:apply-templates select="*|text()" /></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//q">
			<fo:inline font-style="italic"><xsl:apply-templates select="*|text()" /></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//samp">
			<fo:inline font-family="monospace" font-size="9pt"><xsl:apply-templates select="*|text()" /></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//span">
			<xsl:apply-templates select="*|text()" />
		</xsl:template>
		<xsl:template match="/dati/scheda/body//var">
			<fo:inline font-style="italic" font-family="monospace"><xsl:apply-templates select="*|text()" /></fo:inline>
		</xsl:template>
		<xsl:template match="/dati/scheda/body//presentation">
			<fo:block font-family="monospace" white-space-collapse="false"><xsl:apply-templates select="*|text()" /></fo:block>
		</xsl:template>

</xsl:stylesheet>
